$(document).ready(function(){
    //加载全部试题信息
    $.ajax({
        url:"http://localhost:9999/Question/selectAllQuestion",
        type:"get",
        dataType: "json",
        success :function(rs){
            // document.getElementById("list_1_1").style.setProperty('display','block')
            $("#msg_1_0").bootstrapTable({
                data:rs.data,
                cache:false,
                pageSize:"5",
                pagination:true,
                columns:[
                    {field:'questionid',title:'题目编号'},
                    {field:'questiontype',title:'题目类型'},
                    {field:'questioncontext',title:'试题内容'},
                    {field:'questionscore',title:'试题分数'},
                    {field:'questionanswer',title:'试题答案'},
                    {field:'teacherid',title:'教师编号'},
                    {field:'questionstart',title:'创建时间'},
                    {field:'questionupdate',title:'修改时间'},
                    {field:'questionremark',title:'备注'},
                    {field:'questionissuedate',title:'发布时间'},
                    {field:'questionissue',title:'是否发布'}
                ]
            });
        },
        error:function (rs) {
            alert("抱歉，没有查询到数据");
        }
    })

})
//条件查询试题信息
var clickSelect=function () {
    //创建table
    $.ajax({
        url:"http://localhost:9999/Question/selectQuestionById",
        type:"get",
        dataType: "json",
        data:$("#questi").serialize(),
        success :function(rs){
           // document.getElementById("list_1_1").style.setProperty('display','block')
            $("#msg_1_1").bootstrapTable('destroy');
            $("#msg_1_1").bootstrapTable({
                data:rs.data,
                cache:false,
                pageSize:"5",
                pagination:true,
                columns:[
                    {radio:true,field:'sel',title:'选择',/*function(data){
                        alert(data);
                        }*/},
                    {field:'questionid',title:'题目编号'},
                    {field:'questiontype',title:'题目类型'},
                    {field:'questioncontext',title:'试题内容'},
                    {field:'questionscore',title:'试题分数'},
                    {field:'questionanswer',title:'试题答案'},
                    {field:'teacherid',title:'教师编号'},
                    {field:'questionstart',title:'创建时间'},
                    {field:'questionupdate',title:'修改时间'},
                    {field:'questionremark',title:'备注'},
                    {field:'questionissuedate',title:'发布时间'},
                    {field:'questionissue',title:'是否发布'}
                ]
            });
            document.getElementById("delq").style.display="block";
            document.getElementById("upq").style.display="block";
        },
        error:function (rs) {
            alert("抱歉，没有查询到数据");
        }
    })
}
//插入试题
var insertQues=function () {
    $.ajax({
        url:"http://localhost:9999/Question/insertQuestion",// 获取系统后台插入试题信息接口
        data:$("#insertQ").serialize(),
        type: "get",
        dataType:"json",
        success:function(rs) {
            if (rs.data>0) { //判断返回值，这里根据的业务内容可做调整
                alert("添加成功");
                window.location.href=window.location.href;
                window.location.reload;
                console.info(rs.data);
            } else {
                alert("添加失败,有重复信息")
                return false;
            }
        },
        error:function(rs){
            alert("请添加教师编号")
        }
    });
}
//
var clickAdd=function () {
    document.getElementById("aa").style.display="block";
}
var quesDel=function (questionid) {
   /* var questionid=bootstrapTable({})*/
    $("#msg_1_1").bootstrapTable({data,})
    if (questionid==true)  {
        $.ajax({
            url:"http://localhost:9999/Question/deleteQuestion",
            type:"get",
            dataType: "json",
            data:{"questionid":questionid},
            success :function(rs){
               if (rs.data>0){
               alert("删除成功")
               }
            } ,
            error:function (rs) {
                alert("抱歉，没有查询到数据");
            }
        })
    }
}
